import { fromJS } from "immutable";
import { ADD_HOME_LIST, SCROLL } from "./actionTypes";

const defaultState = fromJS({
    topicList: [
        {
        id: 1,
        title: '社会热点',
        imgUrl: '//upload.jianshu.io/users/upload_avatars/9988193/fc26c109-1ae6-4327-a298-2def343e9cd8.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96'
    },
    {
        id: 2,
        title: '手绘',
        imgUrl: '//upload.jianshu.io/users/upload_avatars/9988193/fc26c109-1ae6-4327-a298-2def343e9cd8.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96'
    },
],
    articalList:[
        {
            id: 1,
            title: '做了这么久的程序员，你知道为什么会有Lambda表达式吗？',
            desc: '享学课堂特邀作者：老顾转载请声明出处！ 前言 Java8有一些新的特性，今天老顾给大家分享一下关于Lambda表达式的由来，一开始感觉Lambd...',
            imgUrl: 'https://upload-images.jianshu.io/upload_images/8622537-d2d70125133714c7.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/360/h/240'
        },
        {
            id: 2,
            title: '做了这么久的程序员，你知道为什么会有Lambda表达式吗？',
            desc: '享学课堂特邀作者：老顾转载请声明出处！ 前言 Java8有一些新的特性，今天老顾给大家分享一下关于Lambda表达式的由来，一开始感觉Lambd...',
            imgUrl: 'https://upload-images.jianshu.io/upload_images/8622537-d2d70125133714c7.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/360/h/240'
        }
    ],
    recommend: [
        {
            id: 1,
            url: 'https://cdn2.jianshu.io/assets/web/banner-s-club-aa8bdf19f8cf729a759da42e4a96f366.png'
        },
        {
            id: 2,
            url: 'https://cdn2.jianshu.io/assets/web/banner-s-club-aa8bdf19f8cf729a759da42e4a96f366.png'
        },
    ],
    articalPage: 1,
    showScroll: true
})
export const TopicReducer = (state=defaultState, action) => {
    switch(action.type){
        case ADD_HOME_LIST:
            return state.set('articalList', state.get('articalList').concat(action.data)).set('articalPage', action.page)
        case SCROLL:
            return state.set('showScroll', action.show)
        default: 
            return state
    }
}